package org.come.Frame;

import com.tool.tcpimg.UIUtils;
import org.come.Jpanel.MountShouhuJpanel;
import org.come.until.FormsManagement;
import org.come.until.Music;

import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class MountShouhuJframe extends JInternalFrame implements MouseListener {
    private int first_x;
    private int first_y;
    private MountShouhuJpanel mountShouhuJpanel;
    public static MountShouhuJframe getMountShouhuJframe() {
        return (MountShouhuJframe)FormsManagement.getInternalForm(2259).getFrame();
    }
public MountShouhuJframe()throws Exception{
    this.setBorder(BorderFactory.createEmptyBorder());
    ((BasicInternalFrameUI)this.getUI()).setNorthPane(null);
    this.setContentPane((Container)(this.mountShouhuJpanel = new MountShouhuJpanel()));
    this.setBackground(UIUtils.Color_BACK);
    this.setBounds(100, 140, 281, 342);
    this.pack();
    this.setDefaultCloseOperation(3);
    this.setVisible(false);
    this.addMouseListener((MouseListener)this);
    this.addMouseMotionListener(new MouseMotionListener(){
        @Override
        public void mouseMoved(final MouseEvent e) {
        }

        @Override
        public void mouseDragged(final MouseEvent e) {
            if (MountShouhuJframe.this.isVisible()) {
                final int x = e.getX() - MountShouhuJframe.this.first_x;
                final int y = e.getY() - MountShouhuJframe.this.first_y;
                MountShouhuJframe.this.setBounds(x + MountShouhuJframe.this.getX(), y + MountShouhuJframe.this.getY(), MountShouhuJframe.this.getWidth(), MountShouhuJframe.this.getHeight());
            }
        }
    });
    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {
        FormsManagement.showForm(2259);
        Music.addyinxiao("关闭窗口.mp3");
        if (e.isMetaDown()) {
            FormsManagement.HideForm(2259);
        }
        else {
            FormsManagement.Switchinglevel(2259);
        }
        this.first_x = e.getX();
        this.first_y = e.getY();
    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }

    public MountShouhuJpanel getMountShouhuJpanel() {
        return mountShouhuJpanel;
    }

    public void setMountShouhuJpanel(MountShouhuJpanel mountShouhuJpanel) {
        this.mountShouhuJpanel = mountShouhuJpanel;
    }
}
